package com.scheduledTask;

import java.text.SimpleDateFormat;
import java.util.Date;
import org.springframework.web.client.RestTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class ScheduledTasks {
	private static final Logger logger = LoggerFactory.getLogger(ScheduledTasks.class);

    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("HH:mm:ss");

    @Autowired
    private RestTemplate restTemplate;
    @Scheduled(fixedRate = 5000)
    public void reportCurrentTime() {
        logger.info("现在时间为:{}", dateFormat.format(new Date()));
        String quote = restTemplate.getForObject("http://localhost:1111/user/properties", String.class);
  	    logger.info("定时请求，返回的结果："+quote.toString());
    }
}
